package com.gitee.gen.inittable;

import cn.shoukaiseki.inittable.ITableBuildInfoService;
import cn.shoukaiseki.inittable.annotation.TableBuild;
import cn.shoukaiseki.inittable.domain.TableColumnInfo;
import cn.shoukaiseki.inittable.utils.TableColumnInfoBuilder;
import cn.shoukaiseki.inittable.utils.TableInfoUtils;

import java.util.List;

import static cn.shoukaiseki.inittable.utils.RedDragonColumnCamelCaseCommon.uniqueId;


@TableBuild(name = "gen_table_column", comment = "代码生成业务表字段",version = 1)
public class GenTableColumnInitTableInfo implements ITableBuildInfoService {


    @Override
    public List<TableColumnInfo> tableColumnInfoList(){
        List<TableColumnInfo> table = TableInfoUtils.tableColumns(
                uniqueId("columnId","编号"),
                TableColumnInfoBuilder.column("	tableId       varchar(64)               null comment '归属表编号',"),
                TableColumnInfoBuilder.column("	columnName    varchar(200)              null comment '列名称',"),
                TableColumnInfoBuilder.column("	columnComment varchar(500)              null comment '列描述',"),
                TableColumnInfoBuilder.column("	columnType    varchar(100)              null comment '列类型',"),
                TableColumnInfoBuilder.column("	javaType      varchar(500)              null comment 'JAVA类型',"),
                TableColumnInfoBuilder.column("	javaField     varchar(200)              null comment 'JAVA字段名',"),
                TableColumnInfoBuilder.column("	isPk          char                      null comment '是否主键（1是）',"),
                TableColumnInfoBuilder.column("	isIncrement   char                      null comment '是否自增（1是）',"),
                TableColumnInfoBuilder.column("	isRequired    char                      null comment '是否必填（1是）',"),
                TableColumnInfoBuilder.column("	isInsert      char                      null comment '是否为插入字段（1是）',"),
                TableColumnInfoBuilder.column("	isEdit        char                      null comment '是否编辑字段（1是）',"),
                TableColumnInfoBuilder.column("	isList        char                      null comment '是否列表字段（1是）',"),
                TableColumnInfoBuilder.column("	isQuery       char                      null comment '是否查询字段（1是）',"),
                TableColumnInfoBuilder.column("	queryType     varchar(200) default 'EQ' null comment '查询方式（等于、不等于、大于、小于、范围）',"),
                TableColumnInfoBuilder.column("	htmlType      varchar(200)              null comment '显示类型（文本框、文本域、下拉框、复选框、单选框、日期控件）',"),
                TableColumnInfoBuilder.column("	dictType      varchar(200) default ''   null comment '字典类型',"),
                TableColumnInfoBuilder.column("	sort          int                       null comment '排序',"),
                TableColumnInfoBuilder.column("	createBy      varchar(64)  default ''   null comment '创建者',"),
                TableColumnInfoBuilder.column("	createTime    datetime                  null comment '创建时间',"),
                TableColumnInfoBuilder.column("	updateBy      varchar(64)  default ''   null comment '更新者',"),
                TableColumnInfoBuilder.column("	updateTime    datetime                  null comment '更新时间'"),
                null
        );

        return table;
    }

//    @Override
//    public List<TableIndexInfo> tableIndexInfoList() {
//        return tableIndexs(
//                index("inventory_reserved_inventory_bom_id_index").indexColumns("inventory_bom_id"),
//                index("inventory_reserved_item_id_index").indexColumns("item_id"),
//                index("inventory_reserved_inventory_bom_item_id_index").indexColumns("inventory_bom_id,item_id"),
//                null
//        );
//    }
//
//    @Override
//    public List<TableTriggerInfo> tableTriggerList() {
//        return tableTriggers(triggerName("inventory_reserved_rowstamp")
//                .triggerSql("create trigger inventory_reserved_rowstamp before update on inventory_reserved FOR EACH ROW\n" +
//                        "begin\n" +
//                        "    set @rowstamp= old.rowstamp;\n" +
//                        "    set NEW.rowstamp=@rowstamp+1;\n" +
//                        "end;\n"));
//    }
}
